/**
 * Project hdmap
 * @author shengjialiang
 * @version v1.0
 */


#include "map_common/Object.h"
#include "ObjBase.h"

/**
 * Object implementation
 */




using namespace std;

namespace Common
{
    CObject::CObject()
        : mID(""), mType(""), mName("")
    {
        this->mID = generateGuid();
    }

    CObject::~CObject()
    {

    }

    std::string CObject::generateGuid()
    {
        GUID guid;
        CoCreateGuid(&guid);
        char cBuffer[64] = { 0 };
        sprintf_s(cBuffer, sizeof(cBuffer),
            "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
            guid.Data1, guid.Data2,
            guid.Data3, guid.Data4[0],
            guid.Data4[1], guid.Data4[2],
            guid.Data4[3], guid.Data4[4],
            guid.Data4[5], guid.Data4[6],
            guid.Data4[7]);
        return std::string(cBuffer);
    }

    std::string CObject::getID()
    {
        return this->mID;
    }

    void CObject::setID(const std::string& in_id)
    {
        this->mID = in_id;
    }

    std::string CObject::getName()
    {
        return this->mName;
    }

    void CObject::setName(const std::string& in_name)
    {
        this->mName = in_name;
    }

    std::string CObject::getType()
    {
        return this->mType;
    }

    void CObject::setType(const std::string& in_type)
    {
        this->mType = in_type;
    }

    CObject* CObject::clone()
    {
        throw std::exception("");
    }

    void CObject::copyTo(CObject* in_pDestObject)
    {
        if (NULL != in_pDestObject)
        {
            in_pDestObject->setID(this->getID());
            in_pDestObject->setName(this->getName());
            in_pDestObject->setType(this->getType());
        }
    }
}